import java.util.ArrayList;
import java.util.Iterator;

public class Test1 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(12);
        list.add(17);
        list.add(10);
        System.out.println(list);//直接打印
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i)+" ");//读取数据
        }
        System.out.println();
        for (int x:list) {
            System.out.print(x+" ");
        }
        System.out.println();
        Iterator<Integer> it = list.iterator();//迭代器
        while (it.hasNext()){
            System.out.print(it.next()+" ");
        }
    }
}
